package com.lzk.auth.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lzk.auth.mapper.SysUserMapper;
import com.lzk.auth.service.SysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzk.model.system.SysUser;
import com.lzk.security.custom.LoginUserInfoHelper;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;


@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements SysUserService {




    @Override
    public SysUser getUserByUsername(String username) {
      LambdaQueryWrapper<SysUser> wrapper=new LambdaQueryWrapper<>();
      wrapper.eq(SysUser::getUsername,username);
      SysUser sysUser = baseMapper.selectOne(wrapper);
      return sysUser;
    }

    @Override
    public Map<String, Object> getCurrentUser() {
        SysUser sysUser = baseMapper.selectById(LoginUserInfoHelper.getUserId());
        Map<String, Object> map = new HashMap<>();
        map.put("name", sysUser.getName());
        map.put("phone", sysUser.getPhone());
        return map;
    }



}
